(function IIFE() {
    console.log('this is the ')
})()

setTimeout(() => {
    (function log() {
        console.log('ck')
    })()
})

foo:for (let i = 0; i < 10; i++) {
    console.log(i)
}

//
// (function add(){
//     let str = 'ckckckckc'
//     let arr = ['c', 'k', 'c', 'k']
//     for (let i = 0; i < str.length; i++) {
//         console.log(str[i])
//     }
//     for (let i = 0; i < arr.length; i++) {
//         console.log(arr[i])
//     }
//     for (const string of str) {
//         console.log(string)
//     }
//     for (const string of arr) {
//         console.log(string)
//     }
// })()

const c = 'str'
console.log(c.toUpperCase())
console.log(c.toUpperCase() === c) // false
console.log(c.toUpperCase() === c) // false
console.log('111')


console.log(c.split(''))
console.log(c.split('').reverse().join('').toUpperCase())


// 最大安全整数是比最大数值要小很多的
console.log(Number.MAX_SAFE_INTEGER) // 9007199254740991
console.log(Number.MAX_VALUE) //1.7976931348623157e+308

// 整数的检测
console.log(Number.isInteger(2.1)); // false
console.log(Number.isInteger(1)); // true
console.log(Number.isNaN(Number('12'))) // false


const num = 3.4
console.log(num.toFixed(3)); // 保留三位小数
const str = '          hhhhaaa       aaa a        '
console.log(str.trim());
console.log(str.trimEnd());
console.log(str.trimStart());
// regex 中\s表示的是空格， g表示的是全局的， 不仅仅是开始和结束
console.log(str.replace(/\s+/g, '11'));
console.log(str.replace('h', 'a'));


// console.log(a.toPrecision( 2 ));
// console.log(42.toPrecision( 2 ));
console.log(42..toPrecision(2));

console.log(Number('abc')) // NaN Not a Number
console.log(NaN + 1); // NaN 输出
console.log(NaN === NaN);
const symbol1 = Symbol('fn')
const symbol2 = Symbol('fn')
// console.log(symbol1 === symbol2);

console.log(isNaN(NaN)); // true
console.log(isNaN(1)); // false

function isInteger(num) {
    if (!Number.isInteger) {
        Number.isInteger = function (num) {
            // 如果没有
            return typeof num === 'number' && num % 1 === 0;
        }
    }
}

console.log(1.1 % 1)
console.log(1.2 % 1)
console.log(2 % 1)

let a = 10 / 'foo'
console.log(a) // NaN
console.log(typeof a) // 'number'

if (!Number.isNaN) {
    Number.isNaN = function (num) {
        return (
            typeof num === 'number' && window.isNaN(num)
        )
    }
}

console.log(1 / 0)

// 深拷贝
const obj = {
    name: 'ck',
    age: 10
}

const newO = JSON.parse(JSON.stringify(obj))
console.log(obj === newO) // 深拷贝
console.log(newO)

function DC(obj) {
    let res = {}
    dC(obj)
    function dC(obj) {
        for (let item in obj) {
            if (typeof obj[item] === 'object' && obj[item]) {
                dC(obj[item])
            } else {
                res[item] = obj[item]
            }
        }
    }
    return res;
}

console.log(DC(obj));

